// vue.config.js
const CompressionWebpackPlugin = require('compression-webpack-plugin')
/**
 * @type {import('@vue/cli-service').ProjectOptions}
 */
module.exports = {
  configureWebpack: config => {
    return {
      externals: {
        vue: 'Vue',
        'vue-router':'VueRouter',
        moment:'moment',
        'element-ui':'ELEMENT'
      },
      plugins: [
        new CompressionWebpackPlugin({
          test: /\.(html|js|css|ttf)$/,
          threshold: 10240,
          deleteOriginalAssets: false
        })
      ]
    }

  },
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        args[0].title = '任务打卡系统'
        args[0].template = './templates/index.html'
        return args
      })
  },
  //publicPath:'/task',
  devServer: {
    proxy: {
      '/api': {
        // 此处的写法，目的是为了 将 /api 替换成 https://www.baidu.com/
        target: 'http://42.193.17.74',
        // 允许跨域
        changeOrigin: true,
        ws: true,
        // pathRewrite: {
        //     '^/api': ''
        // }
      }
    }
  }
}